package com.example.translateappjava.Utils;

import com.google.gson.annotations.SerializedName;

/**
 * Generic API response wrapper class for handling API responses with status code,
 * message, and data payload.
 * @param <T> Type of the data payload in the API response
 */
public class ApiResponse<T> {
    // HTTP status code returned from the API
    @SerializedName("code")
    private int code;

    // Descriptive message from the API response
    @SerializedName("msg")
    private String message;

    // Generic data payload from the API response
    @SerializedName("data")
    private T data;

    /**
     * @return The HTTP status code from the API response
     */
    public int getCode() {
        return code;
    }

    /**
     * @return The descriptive message from the API response
     */
    public String getMessage() {
        return message;
    }

    /**
     * @return The generic data payload from the API response
     */
    public T getData() {
        return data;
    }

    /**
     * Convenience method to check if the API call was successful
     * @return true if the status code is 200 (HTTP OK), false otherwise
     */
    public boolean isSuccessful() {
        return code == 200; // Assuming 200 is the success code
    }
}